<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>mytestAdmin</title>
		<meta name="renderer" content="webkit">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
		<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
		<link rel="stylesheet" href="./css/font.css">
		<link rel="stylesheet" href="./css/xadmin.css">
		<script type="text/javascript" src="js/jquery.min.js"></script>
		<script type="text/javascript" src="./lib/layui/layui.js" charset="utf-8"></script>
		<script type="text/javascript" src="./js/xadmin.js"></script>
		<script src="js/config.js" type="application/javascript"></script>
		<!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
		<!--[if lt IE 9]>
      <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
      <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
	</head>

	<body>
		<div class="x-body">

			<table class="layui-hide" id="jobList" lay-filter="jobList"></table>

		</div>
		<script>
			var id;
			var intervalId1;
			layui.use(['layer'], function() {
				var layer = layui.layer;
				var router = layui.router();
				id = router.search.id;
				userid = router.search.userid;
				$.ajax({
					url: base_url + '/testcase/excute/' + id + '',
					type: 'get',
					data: {},
					dataType: 'json',
					success: function(result) {
						intervalId1 = setInterval(aaa, 2000);
						intervalId = setInterval("aaa();", 3000);
					}
				});
			});

			function aaa() {
				var resultname = "";
				if($('#content').html() != '') {
					return;
				}
				$.ajax({
					url: base_url + '/testcase/excute/status/' + id + '',
					type: 'get',
					data: {},
					dataType: 'json',
					success: function(result) {
						if(result.data[0].status != '3' && result.data[0].status != '0' && result.data[0].status != '') {
							$("#loading").hide();
							clearInterval(intervalId1);
							resultname = result.data[0].statusname;
							$.ajax({
								url: base_url + '/testcase/excute/log/' + id + '' + "/0",
								type: 'get',
								data: {},
								dataType: 'json',
								success: function(result) {
									if($('#content').html() != '') {
										return;
									}
									var contents = result.data;
									var i=0;
									$.each(contents, function(key, value) {
										i++
										var name = "l"+i;
										$("#content").append("<li id='"+name+"' style='margin-top:5px'></li>")
										$("#"+name).text(value.log).html();
									});
										
									$("#content").append("<p><b>" + resultname + "</b></p>");
									if(resultname == "通过") {
										$("#content").css("color","green");
									}else{
										$("#content").css("color","red");
									}
								}
							});
						}
					}
				});
			}
		</script>
		<div id="content" class="content" style='padding: 20px; margin-top: -50px; word-wrap:break-word'></div>
		<div id="log"></div>
		<div id="loading" style="background: #FFFFFF;">
			<img src='images/loading.gif' style="text-align: center" width="900" height="900"></img>
		</div>

	</body>

</html>